
var isIE6 = window.XMLHttpRequest?false:true;


function init(){
	if(isIE6){
		enableAlphaImages();
	}
}


function enableAlphaImages() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
	if (itsAllGood) {
		for ( var i = 0; i < document.all.length; i++) {
			var obj = document.all[i];
			var bg = obj.currentStyle.backgroundImage;
			var img = document.images[i];
			if (bg && bg.match(/\.png/i) != null) {
				var img = bg.substring(5, bg.length - 2);
				var offset = obj.style["background-position"];
				obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
						+ img + "', sizingMethod='crop')";
				obj.style.backgroundImage = "url('images/spacer.gif')";// 替换透明PNG的图片
				obj.style["background-position"] = offset; // reapply
			} else if (img && img.src.match(/\.png$/i) != null) {
				var src = img.src;
				img.style.width = img.width + "px";
				img.style.height = img.height + "px";
				img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
						+ src + "', sizingMethod='crop')"
				img.src = "images/spacer.gif";// 替换透明PNG的图片
			}
		}
	}
}

$(function(){
    //进入页面时
/*    $(".tab_content").hide(); //候隐藏所有的content内容
    $("ul.tabs li:first").addClass("current").show(); //激活第一个tab
    $(".tab_content:first").show(); //显示第一个content内容
 
    //点击对应的tab时
    $("ul.tabs li").click(function() {
 
        $("ul.tabs li").removeClass("current"); //将所有的tab去掉active样式
        $(this).addClass("current"); //点击的这个tab加active样式
        $(".tab_content").hide(); //候隐藏所有的content内容
 
        var activeTab = $(this).find("a").attr("href"); 
        $(activeTab).fadeIn();
 
    });    */   
	$("#count").change(countOnChange).keyup(countOnChange).val(1).change();
	$("#top_email").click( function() {var eml = $("#top_email").attr("value",'')} )
			   .blur( function() {
					if($("#top_email").attr("value") == ""){
						eml = $("#top_email").attr("value",'请输入您的邮箱...')};
				} ); 
})


function countOnChange(){
	var price =$('#price').text().match(/[0-9]+\.[0-9]*|[0-9]+/);
	var count = parseInt($('#count').val().match(/\d+/)) || 0;
	$('.total').html('￥' + price * count);
	$('#amount').val(price * count);
}

function copyCode(){
    var testCode='最优质的团购网站——聚点团购http://www.judian.com/';
    if(copy2Clipboard(testCode)!=false){
        alert("复制网址成功，请黏贴到您的QQ/MSN上推荐给你的好友！");
    }
}
copy2Clipboard=function(txt){
    if(window.clipboardData){
        window.clipboardData.clearData();
        window.clipboardData.setData("Text",txt);
    }
    else if(navigator.userAgent.indexOf("Opera")!=-1){
        window.location=txt;
    }
    else if(window.netscape){
        try{
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        }
        catch(e){
            return false;
        }
        var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if(!clip)return;
        var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if(!trans)return;
        trans.addDataFlavor('text/unicode');
        var str=new Object();
        var len=new Object();
        var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext=txt;str.data=copytext;
        trans.setTransferData("text/unicode",str,copytext.length*2);
        var clipid=Components.interfaces.nsIClipboard;
        if(!clip)return false;
        clip.setData(trans,null,clipid.kGlobalClipboard);
    }
}

